package mvc {
	import flash.display.Sprite;

	import mvc.controller.app.AppAddViewCommand;
	import mvc.controller.app.AppRemoveViewCommand;
	import mvc.controller.app.AppStartupCommand;
	import mvc.model.ResourceProxy;
	import mvc.model.ViewProxy;

	import org.puremvc.as3.patterns.facade.Facade;

	public class AppFacade extends Facade {
		public function AppFacade() {
			super();
		}

		protected override function initializeController():void {
			super.initializeController();

			registerCommand(AppNotification.APP_ADD_VIEW, AppAddViewCommand);
			registerCommand(AppNotification.APP_REMOVE_VIEW, AppRemoveViewCommand);
		}

		protected override function initializeModel():void {
			super.initializeModel();

			registerProxy(new ViewProxy());
			registerProxy(new ResourceProxy());
		}

		protected override function initializeView():void {
			super.initializeView(); 
		}

		public static function getInstance():AppFacade {
			if (instance == null)
				instance = new AppFacade();
			return instance as AppFacade;
		}

		public function startup(stage:Sprite):void {
			this.registerCommand(AppNotification.APP_STARTUP, AppStartupCommand);
			sendNotification(AppNotification.APP_STARTUP, stage);
		}
	}
}
